from django.db import models
from dvadmin.utils.models import CoreModel

# Create your models here.

class ProductionPlan(CoreModel):
    """生产计划模型"""
    PLAN_STATUS = (
        (1, '未开始'),
        (2, '进行中'),
        (3, '已完成'),
        (4, '已取消')
    )
    
    plan_name = models.CharField(max_length=100, verbose_name="计划名称")
    product = models.CharField(max_length=100, verbose_name="生产产品")
    plan_quantity = models.IntegerField(verbose_name="计划数量")
    actual_quantity = models.IntegerField(verbose_name="实际完成数量", default=0)
    start_date = models.DateField(verbose_name="计划开始日期")
    end_date = models.DateField(verbose_name="计划结束日期")
    status = models.IntegerField(choices=PLAN_STATUS, default=1, verbose_name="计划状态")
    priority = models.IntegerField(verbose_name="优先级", default=1)
    remarks = models.TextField(verbose_name="备注", null=True, blank=True)

    def __str__(self):
        return self.plan_name

    class Meta:
        db_table = "production_plan"
        verbose_name = '生产计划'
        verbose_name_plural = verbose_name
        ordering = ('-create_datetime',)
